#include <stdio.h>
int main()
{
    int N;
    int F[1001] = {0};
    int k;
    int i;
    int count;
    int temp;
    int max = 0;
    scanf("%d", &N);
    count = N;
    while (count != 0)
    {
        scanf("%d", &k);
        for (i = 0; i < k; i++)
        {
            scanf("%d", &temp);
            F[temp]++;
        }
        count--;
    }
    for (i = 1; i <= 1000; i++)
    {
        if (max < F[i])
            max = F[i];
    }
    for (i = 1000; i > 0; i--)
    {
        if (max == F[i])
        {
            printf("%d %d", i, max);
            break;
        }
    }
    return 0;
}